<?php

include("../conn.php");
include "s-cookie.php";
?>
<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>个人资料-学生端</title>
    <link rel="stylesheet" type="text/css" href="../css/htmleaf-demo.css">
    <link rel="stylesheet" type="text/css" href="../css/nav.css">
    <link rel="stylesheet" type="text/css" href="../fonts/iconfont.css">

    <link rel="stylesheet" href="../css/bootstrap-theme.css"/>

    <script type="text/javascript" src="../js/jquery.min.js"></script>
    <link rel="stylesheet" href="../css/bootstrap-theme.min.css"/>
    <link rel="stylesheet" href="../css/bootstrap.css"/>
    <script type="text/javascript" src="../js/bootstrap3.0.3.min.js"></script>
    <link rel="stylesheet" href="../css/info.css"/>


</head>
<body class="bodycolor">

<nav class="navbar navbar-default navbar-fixed-top" style="clear: left;">
    <div class="container">
        <div class="navbar-right navfont" id="navbar-collapse">
            <p>华软网络技术系毕业管理系统</p>
        </div>
<!--        <a href="t-cookie.php?cookie=out" id="out">退出</a>-->
    </div>

</nav>

<div class="nav topx navbackground-s" id="nav">
    <div>
        <div style="border-bottom:1px solid rgba(255,255,255,.1)"><img src="../images/mini.png"></div>
    </div>
    <ul>
        <li class="nav-item">
            <a href="s-index.php"><i class="my-icon nav-icon icon_2"></i><span>首页</span><i class="my-icon nav-more"></i></a>

        </li>
        <li class="nav-item">
            <a href="s-mykt.php"><i class="my-icon nav-icon icon_1"></i><span>我的课题</span><i
                    class="my-icon nav-more"></i></a>
        </li>

        <li class="nav-item">
            <a href="s-examination.php"><i class="my-icon nav-icon icon_3"></i><span>成绩考核表</span><i
                    class="my-icon nav-more"></i></a>

        </li>
        <li class="nav-item">
            <a href="s-information.php"><i class="my-icon nav-icon icon_4"></i><span>我的资料</span><i
                    class="my-icon nav-more"></i></a>
        </li>
        <li class="nav-item">
            <a href="teachresearch.php"><i class="my-icon nav-icon icon_6"></i><span>选课</span><i
                    class="my-icon nav-more"></i></a>
        </li>
    </ul>
</div>
<div class="indexborder">
    <!--<center>-->
    <div class="box-inline indexdiv1 panel panel-default auto" align="center">
        <div class="themepanel">
            <b>基本资料</b>
        </div>
        <div style="clear:both">
            <hr style="border: solid #295A9B 1px;"/>
        </div>
        <div class="panel-body">
            <div class="a">
                <img id="avatarPreview" src="../img/学生头像.png" title="点击更换图片">
            </div>

            <center>
                <table class="tab panel panel-default" id="table">
                    <?
                    $sid = $_SESSION["s-id"];
                    //查询语句
                    $sql = "select StudentId,StudentName,Sex,Class,email,QQ,Tel,Major from student where StudentId =$sid";


                    $result = mysqli_query($conn, $sql);
                    while ($row = mysqli_fetch_array($result)) {
                        ?>
                        <tr class="c">
                            <td>学号:</td>
                            <td><input type="text" value="<?php echo $row['StudentId']?>" id="input" readonly="readonly"
                                       name="StudentId"/></td>
                        </tr>
                        <tr>
                            <td>&nbsp;</td>
                            <td>&nbsp;</td>
                        </tr>
                        <tr class="c">
                            <td>姓名:</td>
                            <td><input type="text" value="<?php echo $row['StudentName']?>" id="input1"
                                       readonly="readonly" name="StudentName"/></td>
                        </tr>
                        <tr>
                            <td>&nbsp;</td>
                            <td>&nbsp;</td>
                        </tr>
                        <tr class="c">
                            <td>性别:</td>
                            <td><input type="text" value="<?php echo $row['Sex']?>" id="input2" readonly="readonly"
                                       name="sex"/></td>
                        </tr>
                        <tr>
                            <td>&nbsp;</td>
                            <td>&nbsp;</td>
                        </tr>
                        <tr class="c">
                            <td> 班别:</td>
                            <td><input type="text" value="<?php echo $row['Class']?>" id="input3" readonly="readonly"
                                       name="class"/></td>
                        </tr>
                        <tr>
                            <td>&nbsp;</td>
                            <td>&nbsp;</td>
                        </tr>
                        <tr class="c">
                            <td>手机:</td>
                            <td><input type="text" value="<?php echo $row['Tel']?>" id="input4" readonly="readonly"
                                       name="Tel"/></td>
                        </tr>
                        <tr>
                            <td>&nbsp;</td>
                            <td>&nbsp;</td>
                        </tr>
                        <tr class="c">
                            <td>E-mail:</td>
                            <td><input type="email" value="<?php echo $row['email']?>" id="input5" readonly="readonly"
                                       name="email"/></td>
                        </tr>
                        <tr>
                            <td>&nbsp;</td>
                            <td>&nbsp;</td>
                        </tr>
                        <tr class="c">
                            <td>QQ:</td>
                            <td><input type="text" value="<?php echo $row['QQ']?>" id="input6" readonly="readonly"
                                       name="qq"/></td>
                        </tr>
                        <tr>
                            <td>&nbsp;</td>
                            <td>&nbsp;</td>
                        </tr>
                        <tr class="c">
                            <td> 系别:</td>
                            <td><input type="text" value="<?php echo $row['Major']?>" id="input7" readonly="readonly"
                                       name="depart"/></td>
                        </tr>
                        <tr>
                            <td>&nbsp;</td>
                            <td>&nbsp;</td>
                        </tr>
                    <?php
                    }
                    ?>
                    <tr class="c">
                        <td></td>

                        <td>
                            <button id="edit" name="edited" onclick="change()" style="color:white">修改</button>

                            <button id="save" name="saved" value="s-manage" onclick="save(this)" style="color:white">
                                保存
                            </button>
                        </td>
                    </tr>
                </table>
            </center>
        </div>
    </div>
    <!--</center>-->

</div>
<!--<footer class="indexfooter container-fluid  bottom">
    <p class="footer-p" align="center">地址：广东省广州市从化区经济开发区高技术产业园广从南路548号 | 电话：020－87818918 邮编：510990 | 网站公安备案编号：4401840100050 粤ICP备：05085382号 站长统计</p>
</footer>-->


<script>
    window.jQuery || document.write('<script src="js/jquery-1.11.0.min.js"><\/script>')
</script>
<script type="text/javascript" src="js/nav.js"></script>
<script type="text/javascript">
    function change() {
        document.getElementById("input1").readOnly = false;
        document.getElementById("input1").style.border = "1px solid #000000";
        document.getElementById("input2").readOnly = false;
        document.getElementById("input2").style.border = "1px solid #000000";
        document.getElementById("input3").readOnly = false;
        document.getElementById("input3").style.border = "1px solid #000000";
        document.getElementById("input4").readOnly = false;
        document.getElementById("input4").style.border = "1px solid #000000";
        document.getElementById("input5").readOnly = false;
        document.getElementById("input5").style.border = "1px solid #000000";
        document.getElementById("input6").readOnly = false;
        document.getElementById("input6").style.border = "1px solid #000000";
        document.getElementById("input7").readOnly = false;
        document.getElementById("input7").style.border = "1px solid #000000";
    }

    function save(t) {
        var a = t;
        var b = a.parentNode.parentNode.parentNode.getElementsByTagName("input");

        var datas = new Array();
        for (var i = 0; i < b.length; i++) {
            datas[i] = encodeURI(b[i].value);

        }

        var msg = "您真的确定要修改吗？\n\n请确认！";
        if (confirm(msg) == true) {
            $.ajax({
                type: "GET",
                url: "manage.php",
                data: "&StudentId=" + datas[0] + "&StudentName=" + datas[1] + "&Sex=" + datas[2] + "&Class=" + datas[3] +
                "&Tel=" + datas[4] + "&email=" + datas[5] + "&QQ=" + datas[6] + "&Depart=" + datas[7] + "&saved=s-change",
                error: function (msg) {
                    return false
                },
                success: function (msg) {
                    alert(msg);
                    myWindow = window.open("s-information.php", "_self");
                }
            });
        }

        for (var i = 0; i < b.length; i++) {
            b[i].readOnly = true;
            b[i].style.border = "0";
        }

    }
</script>
</body>

</html>